﻿using Microsoft.Xna.Framework.Graphics;

namespace xEngine.DataTypes
{
    public class VertexCollection<T> where T : IVertexType
    {
        #region Member Variables

        private T[] _vertices;
        private int _vertexCount;

        public static readonly System.Type VertexType = typeof(T);

        #endregion

        #region Properties

        public VertexDeclaration VertexDeclaration { get { return this[0].VertexDeclaration; } }

        public T this[int index]
        {
            get { return _vertices[index]; }
            set { _vertices[index] = value; }
        }
        public T[] Vertices
        {
            get { return _vertices; }
        }
        public int VertexCount
        {
            get { return _vertexCount; }
        }

        #endregion

        #region Constructors

        public VertexCollection() : this(128) { }
        public VertexCollection(int baseSize)
        {
            _vertexCount = baseSize;
            _vertices = new T[_vertexCount];
        }

        #endregion
    }
}
